/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (nums, target) {
    let indexMap = [];
    let loop = 0, dis = target;
    while(loop < nums.length) {
        dis = target - nums[loop];
        let disIndex = nums.indexOf(dis);
        if (disIndex > -1 && loop - disIndex) {
            return [loop, disIndex];
        }
        loop++;
    }
    return;
};

module.exports = twoSum;